//--------------------------------------------------------
// TABLE A12: Testing sorting between member-staff (House)
//--------------------------------------------------------

clear
use masterdata_house.dta

gen ln_meansalary = ln(meansalary +1)
gen nolobstaff = numstaff - futurelob
gen femaleratio = numfemale/numstaff

replace totbill = 0 if totbill==.
sort icpsr congress
by icpsr, sort: gen numstaff_lag = numstaff[_n-1]
by icpsr, sort: gen nolobstaff_lag = nolobstaff[_n-1]
by icpsr, sort: gen salary_lag = ln_meansalary[_n-1]
by icpsr, sort: gen majority_lag = majority[_n-1]
by icpsr, sort: gen chair_lag = chair[_n-1]
by icpsr, sort: gen subchr_lag = subchr[_n-1]
by icpsr, sort: gen power_lag = power[_n-1]
by icpsr, sort: gen budget_lag = budget[_n-1]
by icpsr, sort: gen seniority_lag = seniority[_n-1]
by icpsr, sort: gen maj_leader_lag = maj_leader[_n-1]
by icpsr, sort: gen min_leader_lag = min_leader[_n-1]
by icpsr, sort: gen femaleratio_lag = femaleratio[_n-1]
by icpsr, sort: gen futurelob_lag = futurelob[_n-1]
by icpsr, sort: gen totbill_lag = totbill[_n-1]
by icpsr, sort: gen ss_bills_lag = ss_bills[_n-1]


macro define member_char1 "leslag totbill_lag ss_bills_lag majority_lag budget_lag chair_lag subchr_lag seniority_lag maj_leader_lag min_leader_lag power_lag dem membecamelob female afam latino state_leg south_dem"
macro define member_char2 "leslag totbill_lag ss_bills_lag majority_lag budget_lag chair_lag subchr_lag seniority_lag maj_leader_lag min_leader_lag power_lag"
macro define staff_char1 "numstaff_lag salary_lag femaleratio_lag"

eststo clear
eststo: quietly reg futurelob $member_char1 $staff_char1 i.congress, vce(cluster icpsr)
eststo: quietly areg futurelob $member_char2 $staff_char1 i.congress, a(icpsr) vce(cluster icpsr)
esttab, star(* 0.10 ** 0.05 *** 0.01) drop(*congress*) se ar2

